package com.smartleanx.module.hrm.controller.admin.welcomemessage;

import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;

import com.smartleanx.framework.common.pojo.PageParam;
import com.smartleanx.framework.common.pojo.PageResult;
import com.smartleanx.framework.common.pojo.CommonResult;
import com.smartleanx.framework.common.util.object.BeanUtils;
import static com.smartleanx.framework.common.pojo.CommonResult.success;

import com.smartleanx.framework.excel.core.util.ExcelUtils;

import com.smartleanx.framework.operatelog.core.annotations.OperateLog;
import static com.smartleanx.framework.operatelog.core.enums.OperateTypeEnum.*;

import com.smartleanx.module.hrm.controller.admin.welcomemessage.vo.*;
import com.smartleanx.module.hrm.dal.dataobject.welcomemessage.WelcomeMessageDO;
import com.smartleanx.module.hrm.service.welcomemessage.WelcomeMessageService;

@Tag(name = "管理后台 - 欢迎语")
@RestController
@RequestMapping("/hrm/welcome-message")
@Validated
public class WelcomeMessageController {

    @Resource
    private WelcomeMessageService welcomeMessageService;

    // @PostMapping("/create")
    // @Operation(summary = "创建欢迎语")
    // @PreAuthorize("@ss.hasPermission('hrm:welcome-message:create')")
    // public CommonResult<Long> createWelcomeMessage(@Valid @RequestBody WelcomeMessageSaveReqVO createReqVO) {
    //     return success(welcomeMessageService.createWelcomeMessage(createReqVO));
    // }
    //
    // @PutMapping("/update")
    // @Operation(summary = "更新欢迎语")
    // @PreAuthorize("@ss.hasPermission('hrm:welcome-message:update')")
    // public CommonResult<Boolean> updateWelcomeMessage(@Valid @RequestBody WelcomeMessageSaveReqVO updateReqVO) {
    //     welcomeMessageService.updateWelcomeMessage(updateReqVO);
    //     return success(true);
    // }

    @PostMapping("/save")
    @Operation(summary = "保存欢迎语")
    @PreAuthorize("@ss.hasPermission('hrm:welcome-message:create')")
    public CommonResult<Long> saveWelcomeMessage(@Valid @RequestBody WelcomeMessageSaveReqVO saveReqVO) {
        return success(welcomeMessageService.saveWelcomeMessage(saveReqVO));
    }

    @GetMapping("/get")
    @Operation(summary = "获得欢迎语")
    @PreAuthorize("@ss.hasPermission('hrm:welcome-message:query')")
    public CommonResult<WelcomeMessageRespVO> getWelcomeMessage() {
        WelcomeMessageDO welcomeMessage = welcomeMessageService.getWelcomeMessage();
        return success(BeanUtils.toBean(welcomeMessage, WelcomeMessageRespVO.class));
    }

    @GetMapping("/isShow")
    @Operation(summary = "是否展示欢迎语")
    @PreAuthorize("@ss.hasPermission('hrm:welcome-message:query')")
    public CommonResult<Boolean> showWelcomeMessage() {
        return success(welcomeMessageService.showWelcomeMessage());
    }

    // @DeleteMapping("/delete")
    // @Operation(summary = "删除欢迎语")
    // @Parameter(name = "id", description = "编号", required = true)
    // @PreAuthorize("@ss.hasPermission('hrm:welcome-message:delete')")
    // public CommonResult<Boolean> deleteWelcomeMessage(@RequestParam("id") Long id) {
    //     welcomeMessageService.deleteWelcomeMessage(id);
    //     return success(true);
    // }
    //
    // @GetMapping("/get")
    // @Operation(summary = "获得欢迎语")
    // @Parameter(name = "id", description = "编号", required = true, example = "1024")
    // @PreAuthorize("@ss.hasPermission('hrm:welcome-message:query')")
    // public CommonResult<WelcomeMessageRespVO> getWelcomeMessage(@RequestParam("id") Long id) {
    //     WelcomeMessageDO welcomeMessage = welcomeMessageService.getWelcomeMessage(id);
    //     return success(BeanUtils.toBean(welcomeMessage, WelcomeMessageRespVO.class));
    // }
    //
    // @GetMapping("/page")
    // @Operation(summary = "获得欢迎语分页")
    // @PreAuthorize("@ss.hasPermission('hrm:welcome-message:query')")
    // public CommonResult<PageResult<WelcomeMessageRespVO>> getWelcomeMessagePage(@Valid WelcomeMessagePageReqVO pageReqVO) {
    //     PageResult<WelcomeMessageDO> pageResult = welcomeMessageService.getWelcomeMessagePage(pageReqVO);
    //     return success(BeanUtils.toBean(pageResult, WelcomeMessageRespVO.class));
    // }

}